package com.hm.system.auto;

import static springfox.documentation.builders.PathSelectors.regex;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.hm.system.util.SystemConfigDef;

import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author shishun.wang
 * @date 2016年5月12日 下午9:55:50
 * @version 1.0
 * @describe
 */
@Configuration
@EnableSwagger2
public class SwaggerAutoConfiguration {

	@Autowired
	private SystemProperties systemProperties;

	@Bean
	public Docket swaggerSpringMvcPlugin() {
		ApiInfo apiInfo = new ApiInfo(systemProperties.getPlatformName(), systemProperties.getOsName(), null, null,
				null, "Private", null);
		Docket docket = new Docket(DocumentationType.SWAGGER_2).select()
				// .paths(regex(".*?.*")).build()
				.paths(regex(".*" + SystemConfigDef.Api.API_PREFIX + ".*")).build().apiInfo(apiInfo)
				.useDefaultResponseMessages(false);
		return docket;
	}
}
